package com.first.core.web.action;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import com.first.core.web.Constants;
import com.first.xiinn.model.User;
import com.opensymphony.xwork2.ActionContext;

public class BaseWebAction{
  /**
   * 将对象保存到ActionContext中
   * @param key		键
   * @param value	键值
   */
  public void setActionContextValue(Object key, Object value){
	  ActionContext.getContext().put(key, value);
  }

  public void execute() {
	  	ActionContext ac = ActionContext.getContext();
		@SuppressWarnings("unchecked")
		Map<String, User> session = ac.getSession();
		User loginWebUser = null;
		if(session!=null){
			loginWebUser =  (User)session.get(Constants.USER_SESSION_KEY);
		}
		setActionContextValue("loginWebUser", loginWebUser);
  }

  protected HttpServletRequest getRequest()
  {
    return ServletActionContext.getRequest();
  }

  protected HttpServletResponse getResponse()
  {
    return ServletActionContext.getResponse();
  }

  protected HttpSession getSession()
  {
    return getRequest().getSession();
  }



  public String list() {
    return "success";
  }

  public String edit() {
    return "input";
  }

  public String save() {
    return "input";
  }

  public String delete() {
    return "success";
  }

  public String multiDelete() {
    return "success";
  }

  public String multiSave() {
    return "success";
  }

}
